/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Game;

import java.awt.*;
import graphics.Animation;

/**
 *
 * @author Yati
 */
public class Tile {

    protected Image image;
    protected Animation currAnim,anim,revAnim;
    protected char type;
    protected boolean colored;
    protected boolean collidable;
    protected boolean playing;//is the animation active

    public Tile(Animation anim,Animation revAnim, char type, boolean collidable) {
        this.image = anim.getImage();
        this.currAnim=anim;
        this.type = type;
        this.collidable = collidable;
        this.playing=false;
        this.anim=anim;
        this.revAnim=revAnim;
    }

    public boolean isCollidable() {
        return collidable;
    }

    public void setCollidable(boolean collidable) {
        this.collidable = collidable;
    }

    public boolean isColored() {
        return colored;
    }

    public void setColored(boolean colored) {
        this.colored = colored;
        setPlaying(colored);
            
    }

    public Image getImage() {
        return image;
    }

    public void setImage(Image image) {
        this.image = image;
    }

    public char getType() {
        return type;
    }

    public void setPlaying(boolean playing) {
        this.playing = true;
        if(playing){
            TileMap.colouredTiles++;
            currAnim=anim;
        }else{
            TileMap.colouredTiles--;
            currAnim=revAnim;
        }
        currAnim.start();
    }
    /**
     * updates the animation of the tile
     *
     * should interperlate between frames
     * The rateOfChange=amountToBeChanged / totalAnimationTime
     *
     * @param elapsedTime
     */
    public void update(long elapsedTime){
        if(playing){
            //play animation here
            image=currAnim.getImage();
            currAnim.update(elapsedTime);
        }
    }




}
